/*
 * Copyright (c) 2006-2018, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2019-03-08     laowang   first version
 */

#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
#include <fal.h>
#include "vconsole.h"

/* defined the LED_RUN_PIN pin: PC1 */
#define LED_RUN_PIN    GET_PIN(C, 1)

int main(void)
{
    //初始化fal
    fal_init();
    /* set LED0 pin mode to output */
    rt_pin_mode(LED_RUN_PIN, PIN_MODE_OUTPUT);

    while (1)
    {
        rt_pin_write(LED_RUN_PIN, PIN_HIGH);
        rt_thread_mdelay(500);
        rt_pin_write(LED_RUN_PIN, PIN_LOW);
        rt_thread_mdelay(500);
    }

    return RT_EOK;
}

static rt_device_t vcom_shell_device = NULL;
static int change_shell(void)
{
    vcom_shell_device = rt_device_find("vcom");
    if (vcom_shell_device)
    {
        vconsole_switch(vcom_shell_device);
    }
    return RT_EOK;
}
INIT_APP_EXPORT(change_shell);

/**
 * Function    ota_app_vtor_reconfig
 * Description Set Vector Table base location to the start addr of app(RT_APP_PART_ADDR).
*/
static int ota_app_vtor_reconfig(void)
{
    #define NVIC_VTOR_MASK   0x3FFFFF80
    /* Set the Vector Table base location by user application firmware definition */
    SCB->VTOR = STM32_FLASH_START_ADRESS & NVIC_VTOR_MASK;

    return 0;
}
INIT_BOARD_EXPORT(ota_app_vtor_reconfig);

